<template>
  <div>
    <el-card class="box-card" style="margin-left: 100px;margin-bottom: 25px;height: 800px">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="科室分类">
          <el-input v-model="formInline.department_type_name" readonly></el-input>
        </el-form-item>
        <el-form-item label="科室名称" style="margin-left: 50px">
          <el-input v-model="formInline.department_name" readonly></el-input>
        </el-form-item>
        <el-form-item label="医生姓名" style="margin-left: 50px">
          <el-input v-model="formInline.department_name" readonly></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="病人姓名">
          <el-input v-model="formInline.name" readonly></el-input>
        </el-form-item>
        <el-form-item label="病人性别" style="margin-left: 50px">
          <el-input v-model="formInline.gender_name" readonly></el-input>
        </el-form-item>
        <el-form-item label="出生年月" style="margin-left: 50px">
          <el-input v-model="formInline.data_birth" readonly></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="病人血型">
          <el-input v-model="formInline.blood_type_name" readonly></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="病情自述">
          <el-input
            type="textarea"
            v-model="formInline.illness_desc"
            style="width: 600px"
            readonly
          ></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="诊断结果" style="width: 500px">
          <el-input v-model="formInline.diagnosis" readonly></el-input>
        </el-form-item>
        <el-form-item label="是否建议住院">
          <el-input v-model="formInline.is_hospital_name" readonly></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="医生开药">
          <el-input
            type="textarea"
            v-model="formInline.medicine_choice"
            style="width: 600px"
            readonly
          ></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="诊断详情">
          <el-input
            type="textarea"
            v-model="formInline.diagnosis_instructions"
            style="width: 600px"
            readonly
          ></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="缴费状态">
          <el-input v-model="formInline.state_name" readonly></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" class="demo-form-inline">
        <el-row>
          <el-button
            type="danger"
            round
            style="margin-left: 350px"
            @click="goBack"
            >返回</el-button
          >
          <el-button
            type="primary"
            round
            style="margin-left: 30px"
            @click="selectDrugPriceList"
            >查看费用</el-button
          >
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formInline: {
        deptCategoryName: "",
        deptName: "",
        id: "",
        userAccount: "",
        userName: "",
        docAccount: "",
        docName: "",
        docType: "",
        registerDepartment: "",
        drugType: "",
        drugName: "",
        docDiagnostic: "",
        drug: "",
        status: "",
        disease: "",
        isHosAdvice: "",
      },
      drugPriceList: [],
      alertResult: "",
      user: {},
    };
  },
  created() {
    this.selectPatientRegisterById();
  },
  updated() {
    this.diagnosisIsOk();
  },
  methods: {
    selectPatientRegisterById() {
      console.log(this.$route.query.row.id);
      //axios查询病历请求
      this.$axios
        .get(this.$settings.BASE_URL+`outpatient/patient_get/${this.$route.query.row.id}/`)
        .then((Response) => {
          this.formInline = Response.data.info;
          console.log(this.formInline)
        })
        .catch((error) => {
          console.error(error);
        });
    },
    selectDrugType() {
      //axios查询药品类型请求
      this.$axios
        .post("/drug/selectDrugType")
        .then((Response) => {
          this.drugType = Response.data;
        })
        .catch((error) => {
          console.error(error);
        });
    },
    drug_1(drug) {
      console.log(drug.drugType);
      this.selectDrugName(drug.drugType);
    },
    goBack() {
      this.$confirm("确认返回到 [ 诊断数据 ] 界面？")
        .then((_) => {
          this.$router.push({
            path: "/index/docView",
          });
        })
        .catch((_) => {

        });
    },
    diagnosisIsOk() {
      var drugList = this.formInline.drug;
      //axios查询药品价格请求
      this.$axios
        .post("/register/payDrugPrice", {
          drug: drugList,
        })
        .then((Response) => {
          var resultList = Response.data;
          var alertResult = "药品价格：";
          for (var j = 0; j < resultList.length; j++) {
            if (resultList[j] != null) {
              alertResult = alertResult + "\n" + resultList[j];
            }
          }
          this.alertResult = alertResult;
        })
        .catch((error) => {
          console.error(error);
        });
      // var tip = this.alertResult;
      // this.$confirm(tip)
      //   .then((_) => {})
      //   .catch((_) => {});
    },
    selectDrugPriceList() {
      console.log(this.alertResult);
      var tip = `[ ${this.formInline.cost} ] 元`;
      this.$confirm(tip)
        .then((_) => {})
        .catch((_) => {});
    },
  },
};
</script>

<style>
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  width: 1080px;
  height: 1000px;
}
</style>